#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright @ 2014 OPS, Qunar Inc. (qunar.com)
#
# Author: tingfang.bao <tingfang.bao@qunar.com>
# DateTime: 15-3-10 下午12:21

from flask import current_app, Blueprint, render_template
from model import db
from model.user import User

admin_bp = Blueprint("admin", __name__, url_prefix='/admin', template_folder="templates")


@admin_bp.route('/')
def index():
    user = User("baotingfang", "tingfang.bao@qunar.com")
    db.session.add(user)
    db.session.commit()
    return render_template(current_app.config['INDEX_TEMPLATE'])


@admin_bp.route('/initdb')
def init_db():
    db.create_all()
    return 'init db successfully!'